{extend name="layout"}

{block name="main"}
<section class="Hui-article-box">
    <nav class="breadcrumb"><i class="Hui-iconfont"></i> 首页
        <span class="c-gray en">&gt;</span>
        帖子管理
        <span class="c-gray en">&gt;</span>
        帖子列表
        <a class="btn btn-success radius r" style="line-height:1.6em;margin-top:3px" href="javascript:location.replace(location.href);" title="刷新"><i class="Hui-iconfont"></i></a>
    </nav>
    <div class="Hui-article">
        <article class="cl pd-20">
            <div class="text-c">
                <form action="">
                    <span class="select-box inline">
				    <select name="typeid" class="select">
					    <option value="0">全部分类</option>
					    <option value="1" {if request()->get('typeid') == 1}selected{/if}>有毛</option>
					    <option value="2" {if request()->get('typeid') == 2}selected{/if}>求毛</option>
                        <option value="3" {if request()->get('typeid') == 3}selected{/if}>赚毛</option>
				    </select>
				    </span>
                    日期范围：
                    <input type="text" name="begintime" onfocus="WdatePicker()" id="logmin" class="input-text Wdate" style="width:120px;" value="{:request()->get('begintime')}">
                    -
                    <input type="text" name="endtime" onfocus="WdatePicker()" id="logmax" class="input-text Wdate" style="width:120px;" value="{:request()->get('endtime')}">
                    <input type="text" name="keywords"  placeholder="关键词" style="width:250px" class="input-text" value="{:request()->get('keywords')}">
                    <button name="" id="" class="btn btn-success" type="submit"><i class="Hui-iconfont"></i> 搜索</button>
                </form>

            </div>
            <!--<div class="cl pd-5 bg-1 bk-gray mt-20">-->
				<!--<span class="l">-->
				<!--<a href="javascript:;" onclick="datadel()" class="btn btn-danger radius"><i class="Hui-iconfont"></i> 批量删除</a>-->
				<!--<a class="btn btn-primary radius" data-title="添加资讯" _href="article-add.html" onclick="article_add('添加资讯','article-add.html')" href="javascript:;"><i class="Hui-iconfont"></i> 添加资讯</a>-->
				<!--</span>-->
                <!--<span class="r">共有数据：<strong>54</strong> 条</span>-->
            <!--</div>-->
            <div class="mt-20">
                <div id="DataTables_Table_0_wrapper" class="dataTables_wrapper no-footer">
                    <!--<div class="dataTables_length" id="DataTables_Table_0_length"><label>显示 <select name="DataTables_Table_0_length" aria-controls="DataTables_Table_0" class="select"><option value="10">10</option><option value="25">25</option><option value="50">50</option><option value="100">100</option></select> 条</label></div>-->

                    <table class="table table-border table-bordered table-bg table-hover table-sort dataTable no-footer" id="DataTables_Table_0" role="grid" aria-describedby="DataTables_Table_0_info">
                    <thead>
                    <tr class="text-c" role="row">
                        <th width="25" class="sorting_disabled" rowspan="1" colspan="1" aria-label="" style="width: 25px;"><input type="checkbox" name="" value=""></th>
                        <th width="80" class="sorting_desc" tabindex="0" aria-controls="DataTables_Table_0" rowspan="1" colspan="1" aria-sort="descending" aria-label="ID: 升序排列" style="width: 80px;">ID</th>
                        <th class="sorting" tabindex="0" aria-controls="DataTables_Table_0" rowspan="1" colspan="1" aria-label="标题: 升序排列" style="width: 1307px;">帖子</th><th width="80" class="sorting" tabindex="0" aria-controls="DataTables_Table_0" rowspan="1" colspan="1" aria-label="分类: 升序排列" style="width: 80px;">分类</th>
                        <th width="130" class="sorting" tabindex="0" aria-controls="DataTables_Table_0" rowspan="1" colspan="1" aria-label="更新时间: 升序排列" style="width: 120px;">发布时间</th>
                        <th width="75" class="sorting" tabindex="0" aria-controls="DataTables_Table_0" rowspan="1" colspan="1" aria-label="浏览次数: 升序排列" style="width: 75px;">评论次数</th>

                        <th width="120" class="sorting_disabled" rowspan="1" colspan="1" aria-label="操作" style="width: 120px;">操作</th></tr>
                    </thead>
                    <tbody>

                    {volist name="threads" id="vo"}
                    <tr class="text-c odd" role="row">
                        <td><input type="checkbox" value="" name=""></td>
                        <td class="sorting_1">{$vo.tid}</td>
                        <td class="text-l"><u style="cursor:pointer" class="text-primary" onclick="article_edit('查看','/admin/index/reply','{$vo.tid}')" title="查看">{$vo.subject}<span style="color: red">{if $vo.user.nickname}「{$vo.user.nickname}」{/if}</span></u></td>
                        <td>
                            {if $vo.typeid == 1 }有毛
                            {elseif $vo.typeid == 2 }求毛
                            {else /}赚毛
                            {/if}
                        </td>
                        <td>{$vo.create_time}</td>
                        <td>{$vo.replies}</td>
                        <td class="f-14 td-manage">

                            <a style="text-decoration:none" class="ml-5" onclick="article_del(this,'{$vo.tid}')" href="javascript:;" title="删除"><i class="Hui-iconfont"></i></a>
                            {if $vo.digest == 0}
                            <a style="text-decoration:none" class="ml-5" onclick="article_god(this,'{$vo.tid}')" href="javascript:;" title="加精"><i class="icon Hui-iconfont" style="color: orangered"></i></a>
                            {/if}

                            {if $vo.closed == 0}
                            <a style="text-decoration:none" class="ml-5" onclick="article_display(this,'{$vo.tid}',1)" href="javascript:;" title="隐藏"><i class="icon Hui-iconfont" style="color: blue"></i></a>
                            {else /}
                            <a style="text-decoration:none" class="ml-5" onclick="article_display(this,'{$vo.tid}',0)" href="javascript:;" title="显示"><i class="icon Hui-iconfont" style="color: black"></i></a>
                            {/if}
                        </td>
                    </tr>
                    {/volist}
                    </tbody>
                </table>
                    {$threads|raw}
                    <!--<div class="dataTables_info" id="DataTables_Table_0_info" role="status" aria-live="polite">显示 1 到 2 ，共 2 条</div>-->
                    <!--<div class="dataTables_paginate paging_simple_numbers" id="DataTables_Table_0_paginate"><a class="paginate_button previous disabled" aria-controls="DataTables_Table_0" data-dt-idx="0" tabindex="0" id="DataTables_Table_0_previous">上一页</a><span><a class="paginate_button current" aria-controls="DataTables_Table_0" data-dt-idx="1" tabindex="0">1</a></span><a class="paginate_button next disabled" aria-controls="DataTables_Table_0" data-dt-idx="2" tabindex="0" id="DataTables_Table_0_next">下一页</a></div>-->
                </div>
            </div>
        </article>
    </div>
</section>
{/block}


{block name="js"}
<script type="text/javascript" src="/lib/My97DatePicker/4.8/WdatePicker.js"></script>
<script type="text/javascript" src="/lib/datatables/1.10.0/jquery.dataTables.min.js"></script>
<script type="text/javascript" src="/lib/laypage/1.2/laypage.js"></script>
<script type="text/javascript">
    // $('.table-sort').dataTable({
    //     "aaSorting": [[ 1, "desc" ]],//默认第几个排序
    //     "bStateSave": true,//状态保存
    //     "aoColumnDefs": [
    //         //{"bVisible": false, "aTargets": [ 3 ]} //控制列的隐藏显示
    //         {"orderable":false}// 不参与排序的列
    //     ]
    // });

    /*资讯-添加*/
    function article_add(title,url,w,h){
        var index = layer.open({
            type: 2,
            title: title,
            content: url
        });
        layer.full(index);
    }
    /*资讯-编辑*/
    function article_edit(title,url,id,w,h){

        var index = layer.open({
            type: 2,
            title: title,
            shadeClose: true,
            shade: false,
            maxmin: true, //开启最大化最小化按钮
            area: ['893px', '600px'],
            content: url+'?tid='+id
        });

        layer.full(index);
    }
    /*资讯-删除*/
    function article_del(obj,id){
        layer.confirm('确认要删除吗？',function(index){
            $.post("/admin/index/delThread",{id:id},function (e) {
                if(e.code == 200){
                    $(obj).parents("tr").remove();
                    layer.msg('已删除!',{icon:1,time:1000});
                }else{
                    layer.msg('删除失败!',{icon:2,time:1000});
                }
            })
        });
    }

    function article_god(obj,id) {
        layer.confirm('确认要加精吗？',function(index){
            $.post("/admin/index/godThread",{id:id},function (e) {
                if(e.code == 200){
                    layer.msg('已加精!',{icon:1,time:1000});
                    window.location.reload();
                }else{
                    layer.msg('加精失败!',{icon:2,time:1000});
                }
            })
        });
    }

    function article_display(obj,id,data) {
        if(data == 1){
            var m = '隐藏';
        }else{
            var m = '显示';
        }
        layer.confirm('确认要'+m+'吗？',function(index){
            $.post("/admin/index/displayThread",{id:id,data:data},function (e) {
                if(e.code == 200){
                    layer.msg('已'+m+'!',{icon:1,time:1000});
                    window.location.reload();
                }else{
                    layer.msg(''+m+'失败!',{icon:2,time:1000});
                }
            })
        });
    }

    /*资讯-审核*/
    function article_shenhe(obj,id){
        layer.confirm('审核文章？', {
                btn: ['通过','不通过','取消'],
                shade: false,
                closeBtn: 0
            },
            function(){
                $(obj).parents("tr").find(".td-manage").prepend('<a class="c-primary" onClick="article_start(this,id)" href="javascript:;" title="申请上线">申请上线</a>');
                $(obj).parents("tr").find(".td-status").html('<span class="label label-success radius">已发布</span>');
                $(obj).remove();
                layer.msg('已发布', {icon:6,time:1000});
            },
            function(){
                $(obj).parents("tr").find(".td-manage").prepend('<a class="c-primary" onClick="article_shenqing(this,id)" href="javascript:;" title="申请上线">申请上线</a>');
                $(obj).parents("tr").find(".td-status").html('<span class="label label-danger radius">未通过</span>');
                $(obj).remove();
                layer.msg('未通过', {icon:5,time:1000});
            });
    }
    /*资讯-下架*/
    function article_stop(obj,id){
        layer.confirm('确认要下架吗？',function(index){
            $(obj).parents("tr").find(".td-manage").prepend('<a style="text-decoration:none" onClick="article_start(this,id)" href="javascript:;" title="发布"><i class="Hui-iconfont">&#xe603;</i></a>');
            $(obj).parents("tr").find(".td-status").html('<span class="label label-defaunt radius">已下架</span>');
            $(obj).remove();
            layer.msg('已下架!',{icon: 5,time:1000});
        });
    }

    /*资讯-发布*/
    function article_start(obj,id){
        layer.confirm('确认要发布吗？',function(index){
            $(obj).parents("tr").find(".td-manage").prepend('<a style="text-decoration:none" onClick="article_stop(this,id)" href="javascript:;" title="下架"><i class="Hui-iconfont">&#xe6de;</i></a>');
            $(obj).parents("tr").find(".td-status").html('<span class="label label-success radius">已发布</span>');
            $(obj).remove();
            layer.msg('已发布!',{icon: 6,time:1000});
        });
    }
    /*资讯-申请上线*/
    function article_shenqing(obj,id){
        $(obj).parents("tr").find(".td-status").html('<span class="label label-default radius">待审核</span>');
        $(obj).parents("tr").find(".td-manage").html("");
        layer.msg('已提交申请，耐心等待审核!', {icon: 1,time:2000});
    }
</script>

{/block}